﻿using Abp.Application.Services;
using Hicap.AuthorizationServer.Core.Common;
using Hicap.AuthorizationServer.Core.Domains.Sys.Notification;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Hicap.AuthorizationServer.Sys.AppService
{
    public class NotifyAppService : ApplicationService
    {
        private readonly INotificationManager _notificationManager;

        public NotifyAppService(INotificationManager notificationManager)
        {
            _notificationManager = notificationManager;
        }

        [HicapAuthorize(SpeicaAuthCode.UserActive)]
        public void FinishedMessage(List<int> idList)
        {
            _notificationManager.FinishedMessage(idList);
        }

        [AllowAnonymous]
        [HttpGet]
        public async Task<IActionResult> CheckHealth()
        {
            await _notificationManager.ReadMessage(NotificationType.UserActive);

            return new OkResult();
        }
    }
}